﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Menu.Master" AutoEventWireup="true" CodeBehind="OrdenCorteForm.aspx.cs" Inherits="Emporium_Web.OrdenCorteForm" Theme="Constellation" %>

<%@ MasterType VirtualPath="~/Menu.master" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxToolkit" %>

<%@ Register src="Search/OrdenProduccionSearch.ascx" tagname="OrdenProduccionSearch" tagprefix="uc4" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <script type="text/javascript" src="js/funciones.grid.js"></script>          
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <!-- Content -->
    <article class="container_12">
	  
		<section class="grid_12">
			<div class="block-border">
			<form runat="server" class="block-content form" id="table_form">
				<h1>Orden de Corte</h1>
                 <ajaxtoolkit:toolkitscriptmanager ID="toolk" runat="server"  EnableScriptGlobalization="true" EnableScriptLocalization="true" EnablePageMethods="true"></ajaxtoolkit:toolkitscriptmanager>
                
                <asp:UpdatePanel ID="upnOrdenCorte" runat="server">
                <ContentTemplate>  
             
                <ul class="message warning no-margin" runat="server"  id="warningMessage">
					<li><asp:Label runat="server" ID="lblWarningMessage"></asp:Label></li>
				</ul>
                <ul class="message error no-margin" runat="server" id="errorMessage">
                    <li>
                        <asp:Label runat="server" ID="lblErrorMessage"></asp:Label></li>
                </ul>    

                 <ajaxtoolkit:TabContainer ID="tbcPedido" runat="server" ActiveTabIndex="0">
                 <ajaxtoolkit:TabPanel ID="TabPanel1" runat="server">
                 <HeaderTemplate>Datos Generales</HeaderTemplate>
                 <ContentTemplate>

                 <fieldset>  
                    <br />
                    <div style="width: 100%; height: 45px;">
                        <div style="width: 125px; float: left;">
                            <label>Nro O.Corte</label>
                        </div>
                        <div align="left" style="float: left;">
                            <asp:TextBox ID="txtCodigo" runat="server" Width="120px" Enabled="False" Style="text-align:right;"></asp:TextBox>                            
                        </div>
                        <div style="width: 125px; float: left;padding-left:30px;">
                            <label>Estado</label>
                        </div>
                        <div align="left" style="float: left;">
                            <asp:TextBox ID="txtEstado" runat="server" Width="150px" Enabled="False"></asp:TextBox>                            
                        </div>
                    </div>  
                    <div style="width: 100%; height: 45px;">
                        <div style="width: 125px; float: left;">
                            <label>Fecha Registro</label>
                        </div>
                        <div align="left" style="float: left;">
                            <asp:TextBox ID="txtFechaRegistro" runat="server" Width="120px" Enabled="False"></asp:TextBox>                            
                        </div>
                    </div>                     
                                                        
                    <div style="width: 100%; height: 45px; float: inherit;">
                        <div style="width: 125px; float: left;">
                            <label>
                                O.P.</label>
                        </div>
                        <div align="left" style="width: 80%; float: left;">
                            <uc4:OrdenProduccionSearch ID="OrdenProduccionSearch1" runat="server" ValidationGroup="OrdenCorteValidation" OnSeleccionado="OrdenProduccionSearch_Seleccionado"/>
                        </div>
                    </div>

                    <div style="width: 100%; height: 45px; float: inherit;">
                        <div style="width: 125px; float: left;">
                            <label>
                                Estilo</label>
                        </div>
                        <div align="left" style="width: 70%; float: left;">
                            <asp:TextBox ID="txtEstilo" runat="server" Width="120px" Enabled="False"></asp:TextBox>                            
                        </div>
                    </div>

                    <div style="width: 100%; height: 45px; float: inherit;">
                        <div style="width: 125px; float: left;">
                            <label>
                                Referencia</label>
                        </div>
                        <div align="left" style="width: 70%; float: left;">
                            <asp:TextBox ID="txtReferencia" runat="server" Width="120px" MaxLength="15"></asp:TextBox>   
                            <asp:RequiredFieldValidator ID="reqReferencia" runat="server" ControlToValidate="txtReferencia" Text="Este campo es obligatorio" ValidationGroup ="OrdenCorteValidation" />                                                   
                        </div>
                    </div>
                    
                          
                    <div style="width: 100%; height: 45px; float: inherit;">
                        <div style="width: 125px; float: left;">
                            <label>
                                Tela</label>
                        </div>
                        <div align="left" style="width: 70%; float: left;">
                            <asp:DropDownList ID="ddlTela" runat="server" Width="50%" AutoPostBack="True" 
                                onselectedindexchanged="ddlTela_SelectedIndexChanged">                              
                            </asp:DropDownList>   
                            <asp:RequiredFieldValidator id="reqTela" ControlToValidate="ddlTela" ErrorMessage="Seleccione una Tela." Display="Static" 
                            InitialValue="0" runat="server"  ValidationGroup="OrdenCorteValidation"/>                         
                        </div>
                    </div> 
                    
                     <div style="width: 100%; height: 45px; float: inherit;">
                        <div style="width: 125px; float: left;">
                            <label>
                                Etiqueta</label>
                        </div>
                        <div align="left" style="width: 70%; float: left;">
                            <asp:DropDownList ID="ddlEtiqueta" runat="server" Width="30%" 
                                AutoPostBack="True" onselectedindexchanged="ddlEtiqueta_SelectedIndexChanged">
                                
                            </asp:DropDownList>
                            <asp:RequiredFieldValidator id="reqEtiqueta" ControlToValidate="ddlEtiqueta" ErrorMessage="Seleccione una Etiqueta." Display="Static" 
                            InitialValue="0" runat="server"  ValidationGroup="OrdenCorteValidation"/>                                                     
                        </div>
                    </div>
                    
                     <div style="width: 100%; height: 45px; float: inherit;">
                        <div style="width: 125px; float: left;">
                            <label>Color</label>
                        </div>
                        <div align="left" style="width: 70%; float: left;">
                            <asp:DropDownList ID="ddlColor" runat="server" Width="30%">
                            </asp:DropDownList>             
                             <asp:RequiredFieldValidator id="reqColor" ControlToValidate="ddlColor" ErrorMessage="Seleccione un Color." Display="Static" 
                            InitialValue="0" runat="server"  ValidationGroup="OrdenCorteValidation"/>               
                        </div>
                    </div> 

                     <div style="width: 100%; height: 45px; float: inherit;">
                        <div style="width: 125px; float: left;">
                            <label>
                                Nro Paños</label>
                        </div>
                        <div align="left" style="width: 70%; float: left;">
                            <asp:TextBox ID="txtPanos" name="simple-required" runat="server" Width="120px" MaxLength="3" Style="text-align:right;" onKeyPress ='return ValidarInputNumerico(event)'></asp:TextBox>
                            <asp:RequiredFieldValidator ID="reqPanos" runat="server" ControlToValidate="txtPanos" Text="Este campo es obligatorio" ValidationGroup ="OrdenCorteValidation" />                                                   
                        </div>
                    </div>
                                
                </fieldset>

                </ContentTemplate>
                </ajaxtoolkit:TabPanel>


               
                <ajaxtoolkit:TabPanel ID="TabPanel2" runat="server">
                <HeaderTemplate>Proporciones</HeaderTemplate>
                <ContentTemplate>

                <fieldset>
                 <br />
                 <div style="width:75%; float:left;" align="left">                    
                   
					 <asp:GridView ID="gvProporciones" runat="server" SkinID="gridviewSkin" 
                             PageSize="20" Width="100%"
                            AutoGenerateColumns="False" ShowFooter="True" 
                         DataKeyNames = "OrdCorPro_Secuencia" onrowcommand="gvProporciones_RowCommand" 
                         onrowdeleting="gvProporciones_RowDeleting">
                        <HeaderStyle Font-Bold="True"/>                     
                        <Columns>                            
                                     
                             <asp:TemplateField HeaderText="Secuencia"  HeaderStyle-HorizontalAlign="Left">
                                <FooterTemplate>
                                    <asp:Label ID="lbl" runat="server"></asp:Label> 
                                 </FooterTemplate>                                                                                           
                                <ItemTemplate> 
                                    <asp:Label ID="lblSecuencia" runat="server" Text='<%# Bind("OrdCorPro_Secuencia","{0:000}") %>'></asp:Label> 
                                </ItemTemplate> 
                                <ItemStyle Width="10%" />
                            </asp:TemplateField>
                                                                          
                           <asp:TemplateField HeaderText="Talla" HeaderStyle-HorizontalAlign="Left">                                 
                                <FooterTemplate>                                     
                                    <asp:DropDownList ID="ddlTallaNew" runat="server" Width="200px"></asp:DropDownList>                                     
                                    <asp:RequiredFieldValidator ID="reqTallaNew" runat="server" ControlToValidate="ddlTallaNew" InitialValue="0" Text="Valor requerido" ValidationGroup ="AgregarProporcion"></asp:RequiredFieldValidator>
                                </FooterTemplate> 
                                <ItemTemplate> 
                                    <asp:Label ID="lblTela" runat="server" Text='<%# Eval("OrdCorPro_Talla") %>'></asp:Label>                                     
                                </ItemTemplate> 
                                <ItemStyle Width="25%" />
                            </asp:TemplateField>

                            <asp:TemplateField HeaderText="Proporción" HeaderStyle-HorizontalAlign="Left">                                 
                                <FooterTemplate>                                     
                                    <asp:TextBox ID="txtProporcionNew" runat="server" Width="120px" MaxLength="3"></asp:TextBox>                                     
                                    <asp:RequiredFieldValidator ID="reqProporcionNew" runat="server" ControlToValidate="txtProporcionNew" Text="Valor requerido" ValidationGroup ="AgregarProporcion"></asp:RequiredFieldValidator>
                                </FooterTemplate> 
                                <ItemTemplate> 
                                    <asp:Label ID="lblProporcion" runat="server" style=" display:none;" Text='<%# Eval("OrdCorPro_Secuencia") %>'></asp:Label> 
                                    <asp:TextBox ID="txtProporcion" runat="server" Width="120px" MaxLength="3" onKeyPress ='return ValidarInputNumerico(event)' onChange='ActualizarProporcion(event,this)' Text='<%# Eval("OrdCorPro_Cantidad") %>' ></asp:TextBox>
                                </ItemTemplate> 
                                <ItemStyle Width="25%" />
                            </asp:TemplateField>
                            
                            <asp:TemplateField ShowHeader="False" HeaderStyle-HorizontalAlign="Left">                                
                                <FooterTemplate> 
                                    <asp:ImageButton ID="imgAdd" runat="server" CausesValidation="True" CommandName="Insert" ValidationGroup = "AgregarProporcion" ImageUrl="~/images/icons/web-app/24/Save.png" ToolTip ="Agregar"></asp:ImageButton> 
                                </FooterTemplate> 
                                 <ItemTemplate> 
                                    <asp:ImageButton ID="imgDelete" runat="server" CausesValidation="False" CommandName="Delete"  ImageUrl="~/images/icons/web-app/24/Delete.png" OnClientClick="return DeleteRegistro();" ToolTip="Eliminar"></asp:ImageButton> 
                                </ItemTemplate>                               
                                 <ItemStyle Width="2%" />
                            </asp:TemplateField>     
                                                 
						</Columns>  						
					</asp:GridView>                    
                    
                </div>				

                    
                </fieldset>			                

                </ContentTemplate>
                </ajaxtoolkit:TabPanel>


               
                <ajaxtoolkit:TabPanel ID="TabPanel3" runat="server">
                <HeaderTemplate>Distribuciones</HeaderTemplate>
                <ContentTemplate>

                <fieldset>
                 <br />
                 <table width="100%">                 
                 <tr>
                   <td style="width:40%;">
                   <div>
					 <asp:GridView ID="gvDistribuciones" runat="server" SkinID="gridviewSkin" 
                             PageSize="20" Width="100%"
                            AutoGenerateColumns="False" ShowFooter="True" 
                         DataKeyNames = "OrdCorDis_Secuencia" 
                         onrowcommand="gvDistribuciones_RowCommand" 
                         onrowdeleting="gvDistribuciones_RowDeleting">
                        <HeaderStyle Font-Bold="True"/>                     
                        <Columns>                            
                                     
                             <asp:TemplateField HeaderText="Secuencia"  HeaderStyle-HorizontalAlign="Left">                                                          
                                <ItemTemplate> 
                                    <asp:Label ID="lblSecuencia" runat="server" Text='<%# Bind("OrdCorDis_Secuencia","{0:000}") %>'></asp:Label> 
                                </ItemTemplate> 
                                <ItemStyle Width="20%" />
                            </asp:TemplateField>
                         
                         
                            <asp:TemplateField HeaderText="Cantidades" HeaderStyle-HorizontalAlign="Left">                                 
                                <FooterTemplate>                                     
                                    <asp:TextBox ID="txtCantidadNew" runat="server" Width="120px" MaxLength="2"></asp:TextBox>                                     
                                    <asp:RequiredFieldValidator ID="reqCantidadNew" runat="server" ControlToValidate="txtCantidadNew" Text="Valor requerido" ValidationGroup ="AgregarCantidad"></asp:RequiredFieldValidator>
                                </FooterTemplate> 
                                <ItemTemplate> 
                                    <asp:Label ID="lblCantidad" runat="server" style=" display:none;" Text='<%# Eval("OrdCorDis_Secuencia") %>'></asp:Label> 
                                    <asp:TextBox ID="txtCantidad" runat="server" Width="120px" MaxLength="3" onKeyPress ='return ValidarInputNumerico(event)' onChange='ActualizarCantidad(event,this)' Text='<%# Eval("OrdCorDis_Cantidad") %>' ></asp:TextBox>
                                </ItemTemplate> 
                                <ItemStyle Width="60%" />
                            </asp:TemplateField>
                            
                            <asp:TemplateField ShowHeader="False" HeaderStyle-HorizontalAlign="Left">                                
                                <FooterTemplate> 
                                    <asp:ImageButton ID="imgAdd" runat="server" CausesValidation="True" CommandName="Insert" ValidationGroup = "AgregarCantidad" ImageUrl="~/images/icons/web-app/24/Save.png" ToolTip ="Agregar"></asp:ImageButton> 
                                </FooterTemplate> 
                                 <ItemTemplate> 
                                    <asp:ImageButton ID="imgDelete" runat="server" CausesValidation="False" CommandName="Delete"  ImageUrl="~/images/icons/web-app/24/Delete.png" OnClientClick="return DeleteRegistro();" ToolTip="Eliminar"></asp:ImageButton> 
                                </ItemTemplate>                               
                                 <ItemStyle Width="20%" />
                            </asp:TemplateField>     
                                                 
						</Columns>  						
					</asp:GridView>
                   </div>               
                   </td>
                   <td style="width:60%;">
                   <table>
                        <tr>
                        <td>
                        <asp:Panel ID = "pnTotalesDistribucion" runat = "server">
                            <table>
                                <tr>  
                                <td style="width:20%">
                                </td>                                  
                                <td>
                                    <asp:Label ID="lblNroPanos" Text="Nro Paños&nbsp;" Width="200px" runat="server" style="text-align:right;"></asp:Label>                                    
                                </td>
                                <td>
                                    <asp:TextBox ID="txtNroPanosPaquetes" runat="server" Width="120px" Enabled="False" style="text-align:center;"></asp:TextBox>                            
                                </td>
                                </tr>

                                <tr>  
                                <td style="width:20%">
                                </td>                                                   
                                <td>
                                    &nbsp;
                                </td>
                                <td>
                                   &nbsp;  
                                </td>
                                </tr>

                                <tr>  
                                <td style="width:20%">
                                </td>                                                   
                                <td>
                                    <asp:Label ID="lblTotalDistribucion" Text="Total Distribucion&nbsp;" Width="200px" runat="server" style="text-align:right;"></asp:Label>                                    
                                </td>
                                <td>
                                     <asp:TextBox ID="txtTotalDistribucion" runat="server" Width="120px" Enabled="False" style="text-align:center;"></asp:TextBox>                          
                                </td>
                                </tr>
                            </table>
                        </asp:Panel>
                        </td>
                        </tr>
                   </table>
                   </td>
                 </tr>
                  <tr>
                 <td>
                    <asp:LinkButton ID="lnkActualizarDistribuciones" runat="server" CssClass="button" 
                        Text="Actualizar" onclick="lnkActualizarDistribuciones_Click" ToolTip="Para actualizar contadores"></asp:LinkButton>
                 </td>
                 <td>
                    
                 </td>
                 </tr>              
                </table>             
                    
                </fieldset>


                  </ContentTemplate>
                </ajaxtoolkit:TabPanel>


               
                <ajaxtoolkit:TabPanel ID="TabPanel4" runat="server">
                <HeaderTemplate>Planilla</HeaderTemplate>
                <ContentTemplate>

                 <fieldset>
                 <br />
                <table width="100%">                 
                 <tr>
                   <td style="width:50%;">
                   <div>
                     <asp:Panel ID = "pnPaquetes" runat="server" Height="450px" ScrollBars="Vertical" Width="100%">
					 <asp:GridView ID="gvPaquetes" runat="server" SkinID="gridviewSkin" 
                             PageSize="1000" Width="100%"
                            AutoGenerateColumns="False" ShowFooter="True" 
                         DataKeyNames = "OrdCorPaq_Numero">
                        <HeaderStyle Font-Bold="True"/>                     
                        <Columns>                            
                                     
                             <asp:TemplateField HeaderText="Nro.Paquete"  HeaderStyle-HorizontalAlign="Left">                                                          
                                <ItemTemplate> 
                                    <asp:Label ID="lblNumero" runat="server" Text='<%# Bind("OrdCorPaq_Numero","{0:000}") %>'></asp:Label> 
                                </ItemTemplate> 
                                <ItemStyle Width="30%" />
                            </asp:TemplateField>
                         
                            <asp:TemplateField HeaderText="Talla"  HeaderStyle-HorizontalAlign="Left">                                                          
                                <ItemTemplate> 
                                    <asp:Label ID="lblTalla" runat="server" Text='<%# Bind("OrdCorPaq_Talla","{0:000}") %>'></asp:Label> 
                                </ItemTemplate> 
                                <ItemStyle Width="30%" />
                            </asp:TemplateField>

                            <asp:TemplateField HeaderText="Prendas" HeaderStyle-HorizontalAlign="Left">                                                                 
                                <ItemTemplate> 
                                    <asp:Label ID="lblNumeroPrenda" runat="server" style=" display:none;" Text='<%# Eval("OrdCorPaq_Numero") %>'></asp:Label> 
                                    <asp:TextBox ID="txtNumeroPrenda" runat="server" Width="120px" MaxLength="3" onKeyPress ='return ValidarInputNumerico(event)' onChange='ActualizarPrendas(event,this)' Text='<%# Eval("OrdCorPaq_Prendas") %>' ></asp:TextBox>
                                </ItemTemplate> 
                                <ItemStyle Width="30%" />
                            </asp:TemplateField>
						</Columns>  						
					</asp:GridView>
                    </asp:Panel>
                   </div>
                    </td>
                   <td style="width:50%;">
                   <table>
                        <tr>
                        <td>
                        <asp:Panel ID = "pnlTotalesPaquetes" runat = "server">
                            <table>
                                <tr>  
                                <td style="width:20%">
                                </td>                                  
                                <td>
                                    <asp:Label ID="lblTotales" runat="server" Text="Total Paquetes&nbsp;"  Width="200px" style="text-align:right;"></asp:Label>
                                </td>
                                <td>
                                    <asp:TextBox ID="txtTotalPaquetes" runat="server" Width="120px" Enabled="False" style="text-align:center;"></asp:TextBox>                            
                                </td>
                                </tr>

                                <tr>  
                                <td style="width:20%">
                                </td>                                                   
                                <td>
                                    &nbsp;
                                </td>
                                <td>
                                   &nbsp;  
                                </td>
                                </tr>

                                <tr>  
                                <td style="width:20%">
                                </td>                                                   
                                <td>
                                    <asp:Label ID="lblPrendasProducir" Text="Prendas a Producir&nbsp;"  Width="200px" runat="server" style="text-align:right;"></asp:Label>                                    
                                </td>
                                <td>
                                     <asp:TextBox ID="txtPrendasProducir" runat="server" Width="120px" Enabled="False" style="text-align:center;"></asp:TextBox>                            
                                </td>
                                </tr>

                                 <tr>  
                                <td style="width:20%">
                                </td>                                                   
                                <td>
                                    &nbsp;
                                </td>
                                <td>
                                   &nbsp;  
                                </td>
                                </tr>

                                 <tr>  
                                <td style="width:20%">
                                </td>                                                   
                                <td>
                                    <asp:Label ID="lblTotalPrendas" Text="Total Prendas&nbsp;" Width="200px" runat="server" style="text-align:right;"></asp:Label>
                                </td>
                                <td>
                                     <asp:TextBox ID="txtTotalPrendas" runat="server" Width="120px" Enabled="False" style="text-align:center;"></asp:TextBox>                            
                                </td>
                                </tr>

                            </table>
                        </asp:Panel>
                        </td>
                        </tr>
                   </table>
                   </td>
                 </tr>
                 
                 <tr>
                 <td>
                    <asp:LinkButton ID="lnkGenerar" runat="server" CssClass="button" 
                        Text="Generar"  ValidationGroup="OrdenCorteValidation" 
                        onclick="lnkGenerar_Click"></asp:LinkButton>
                    <asp:LinkButton ID="lnkActualizarPaquetes" runat="server" CssClass="button" 
                        Text="Actualizar" onclick="lnkActualizarPaquetes_Click" ToolTip="Para actualizar contadores"></asp:LinkButton>
                 </td>
                 <td>
                    
                 </td>
                 </tr>
                </table>                            
                    
                </fieldset>


                 </ContentTemplate>
                 </ajaxtoolkit:TabPanel>

                 </ajaxtoolkit:TabContainer>

                 <br />
                 <fieldset class="grey-bg no-margin">
				<br />
						<asp:LinkButton ID="btnGrabar" runat="server" CssClass="button red" 
                        Text="Grabar"  ValidationGroup="OrdenCorteValidation" 
                        onclick="btnGrabar_Click"></asp:LinkButton>
                        <asp:LinkButton ID="btnAtras" runat="server" CssClass="button red" 
                        Text="Atrás" CausesValidation="false" onclick="btnAtras_Click"></asp:LinkButton>
				</fieldset>

                </ContentTemplate>
                </asp:UpdatePanel>


			</form>
			</div>
		</section>
	</article>  

    <script type="text/javascript">

        function ActualizarProporcion(e, txt) {
            PageMethods.ActualizarProporcion($(txt).parent()[0].children[0].innerHTML, $(txt).parent()[0].children[1].value);

            return false;
        }
        function ActualizarCantidad(e, txt) {
            PageMethods.ActualizarCantidad($(txt).parent()[0].children[0].innerHTML, $(txt).parent()[0].children[1].value);

            return false;
        }

        function ActualizarPrendas(e, txt) {
            PageMethods.ActualizarPrendas($(txt).parent()[0].children[0].innerHTML, $(txt).parent()[0].children[1].value);
          
            return false;
        }        

        function ValidarInputNumerico(e) {
            var valid = "0123456789"
            return ValidaInput(valid, e);
        }
        
        function ValidarInputDecimal(e) {
            var valid = "0123456789.";
            return ValidaInput(valid, e);

        }

        function ValidaInput(valid, e) {
            var keyAscii = (document.all) ? event.keyCode : e.which;
            if (keyAscii != 13) {
                var key = String.fromCharCode(keyAscii);
                var keyAj = key.toUpperCase();
                if (valid == '') {
                    return true;
                }
                if (valid.indexOf(keyAj) == "-1") {
                    if (keyAscii != 8 && keyAscii != 0) { return false };
                    return true;
                }
                return true;
            }
        }

    </script>
</asp:Content>
